package com.J1ay.carsys.dao;

import com.J1ay.carsys.pojo.BowCar;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @Author J1ay
 * @Date 2021/6/2 22:29
 * @Description
 */

public interface BowCarMapper {

    /**
     * @Author J1ay
     * @Date 2021/6/2 23:07
     * @param bowId,sn
     * @Description 根据id或序列号删除租车记录
     * @return
     */

    @Delete("DELETE FROM record WHERE (bowId is not null and bowId = #{bowId}) or (sn is not null and sn = #{sn})")
    int deleteRecord(@Param("bowId") int bowId, @Param("sn") String sn);

    /**
     * @Author J1ay
     * @Date 2021/6/2 23:10
     * @param month
     * @Description 根据月份返回租车记录
     * @return
     */

    @Select("select * from record where (bowEnd is not null and MONTH(bowEnd) = #{month})")
    BowCar[] selectByMonth(@Param("month") int month);

    /**
     * @Author J1ay
     * @Date 2021/6/2 23:10
     * @param year
     * @Description 根据年份返回租车记录
     * @return
     */

    @Select("select * from record where (bowEnd is not null and YEAR(bowEnd) = #{year})")
    BowCar[] selectByYear(@Param("year") int year);

    /**
     * @Author J1ay
     * @Date 2021/6/2 23:11
     * @param bowStatus
     * @Description
     * @return
     */

    @Select("select * from record where bowStatus = #{bowStatus}")
    BowCar[] selectByStatus(@Param("bowStatus") String bowStatus);

    /**
     * @Author J1ay
     * @Date 2021/6/2 23:11
     * @param bowResult
     * @Description
     * @return
     */

    @Select("select * from record where bowResult = #{bowResult}")
    BowCar[] selectByResult(@Param("bowResult") String bowResult);
    /**
     * @Author J1ay
     * @Date 2021/6/2 23:11
     * @param UId
     * @Description
     * @return
     */

    @Select("select * from record where UId = #{UId} and bowResult = 'no'")
    BowCar[] selectByUId(@Param("UId") String UId);
    /**
     * @Author J1ay
     * @Date 2021/6/2 23:14
     * @param bowCar
     * @Description 更新租车记录
     * @return
     */

    void updateRecord(@Param("bowCar") BowCar bowCar);

    /**
     * @Author J1ay
     * @Date 2021/6/2 23:16
     * @param bowCar
     * @Description 增加租车记录
     * @return
     */

    void addRecord(@Param("bowCar") BowCar bowCar);
}
